package m202406.d05;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/6/5 21:32
 */
public class OD_T01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        List<String[]> lines = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String[] split = scanner.nextLine().split("/");
            lines.add(split);
        }
        String[] key = scanner.nextLine().split(" ");
        int level = Integer.parseInt(key[0]);
        String word = key[1];
        int rs = 0;
        for (String[] line : lines) {
            if (line.length > level) {
                if (word.equals(line[level])) {
                    rs++;
                }
            }
        }
        System.out.println(rs);
    }
}
